<?php
/**
 * Created by PhpStorm.
 * User: liu
 * Date: 2018/9/7
 * Time: 0:04
 */

namespace app\admin\model\blog;


use app\admin\model\Base;

class Post extends Base
{
    protected $autoWriteTimestamp='int';
    protected $createTime='created';
    protected $updateTime='updated';
    protected $together=['content'=>['content']];
    public function content(){
        return $this->hasOne(PostContent::class,'post_id','id');
    }
    public function category(){
        return $this->belongsTo(PostCategory::class,'category_id','id');
    }
    public function comments(){
        return $this->hasMany(PostComment::class,'post_id','id')
            ->where(['status'=>0]);
    }
}